package com.romaremez.testuser.src.testsystem;

import com.romaremez.testuser.src.questionanswer.Question;

import java.io.Serializable;

public class QuestionStep implements Serializable {
    private Question question;
    private String userAnswer;

    public QuestionStep(Question question) {
        this.question = question;
    }

    /**
     * Method displays question with shuffled answers.
     */
    public void showQuestion() {
        question.shuffleAnswers();
        displayQuestionAndAnswers();
    }

    @Override
    public boolean equals(Object obj) {
         if (getClass() != obj.getClass()) {
             return false;
         }
         QuestionStep someQuestionStep = (QuestionStep)obj;
        return question.isEqualsQuestions(someQuestionStep.question);
    }

    public void saveAnswer(String userAnswer) {
        this.userAnswer = userAnswer;
    }

    public int getPoints() {
       return question.getPoints(userAnswer);
    }

    private void displayQuestionAndAnswers() {
        System.out.print(question);
    }
}
